<template>
  <div @click="click_tcom">
    <tcom :identifyCode="poro" ref="tc"/>
  </div>
</template>
<script setup>
import tcom from './tcom.vue'
import {ref,onMounted} from 'vue'
var poro = "1235"
const randomNum=(min, max)=>{
  return Math.floor(Math.random() * (max - min) + min)
}
const tc = ref(null)
const identifyCodes = '1234567890abcdefghijklmnopqrstuvwxyz';//验证码输入字串
const click_tcom=()=>{
  poro=""
  makeCode(identifyCodes, 4);
  console.log(poro)
  tc.value.setIdentifyCode(poro)
}
onMounted(()=>{
  click_tcom()
})
// 生成随机验证码
const makeCode=(o, l)=> {
  var numCode = ""
  for (let i = 0; i < l; i++) {
    numCode += identifyCodes[
        randomNum(0,identifyCodes.length)
        ]
  }
  poro = numCode
}

</script>
